package com.wangxin.study8.day;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.temporal.ChronoUnit;

/**
 * @ClassName TimeTest
 * @Description TODO
 * @Author Wangxin
 * @Date 2019-03-01 21:39
 * @Version 1.0
 **/
public class TimeTest {
    public static void main(String[] args) {
        getNow();
        getOneDay();
        getOfEpochDay();
        getYearOfDay();
        System.out.println(until(LocalDate.of(2018,10,1),LocalDate.of(2018,10,2)));
    }
    public static void getNow(){
        LocalDate localDate = LocalDate.now();
        LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.now());
        System.out.println("今天日期："+localDate+"--今天时间："+today);
    }

    public static void getOneDay(){
        LocalDate localDate = LocalDate.of(2018, Month.JANUARY,1);
        System.out.println("2018的第一天："+localDate);
    }

    public static void getOfEpochDay(){
        LocalDate localDate = LocalDate.ofEpochDay(365);
        System.out.println("基准日期点:"+localDate);
    }

    public static void getYearOfDay(){
        LocalDate localDate = LocalDate.ofYearDay(2018,100);
        System.out.println("2018的第100天："+localDate);
    }

    public static long until(LocalDate startDate, LocalDate endDate){
        return startDate.until(endDate, ChronoUnit.DAYS);
    }

}
